/**
 * Created by Administrator on 2017/10/30.
 */
import React from 'react'
import { Grid } from 'antd-mobile';
import './HomeClass.css'
import  HomeClassTitle from './img/class_title.png'
import ClassIcon from './img/class_iten.png'

const data = Array.from(new Array(6)).map((_val, i) => ({
    icon: ClassIcon
}));

class HomeClass extends React.Component{
    constructor(props){
        super(props);
        this.state = {
            HomeClass_data: []
        }
    }
    componentWillReceiveProps(nextProps){
        if(nextProps.HomeClass_data.length>1){
            this.setState({
                HomeClass_data: nextProps.HomeClass_data,
            });
        }
    }
    render(){
        return (
            <div>
                {this.state.HomeClass_data?<div>
                    <div className="HomeClassTitle">
                        <img src={HomeClassTitle} alt=""/>
                    </div>
                    {}
                    <Grid data={this.state.HomeClass_data}
                          columnNum={2}
                          renderItem={dataItem => (
                              <div style={{height:'1.86rem'}}>
                                  <a href={dataItem.web_url}>
                                      <img src={dataItem.image_url} style={{ width: '100%', height: '100%' }} alt="" />
                                  </a>
                              </div>
                          )}
                    />

                </div>:''}
            </div>
        )
    }

}


export default HomeClass